const db = require('../db')
const user = {
    regUser: regUser = (req, res) => {
        const { username, password } = req.body
        const sqlStr = 'insert into users (username,password) values (?,?)'
        //执行
        db.query(sqlStr, [username, password], (err, res1) => {
            if (err) {
                res.send({
                    code: 500,
                    data:err.sqlMessage
                })
                return
            }
            if (res.affectedRows = 1) {
                res.send({
                    code: 200,
                    data: '注册成功'
                })
            }
        })
       
    }
}
module.exports = user